package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;

import com.tool.btn.CommonBtn;
import com.tool.btn.OptionUncheckBtn;
import com.tool.btn.TextBtn;
import com.tool.tcpimg.UIUtils;

/**
 * 基金面板
 * 
 * @author zeng
 * 
 */
public class FundBuyJpanel extends JPanel {

	// 选项卡 30基金 , 60基金 , 90基金
	private OptionUncheckBtn thridFund, sixthFund, ninethFund;
	// 上一页 , 下一页 按钮
	private CommonBtn upPage, downPage;
	// 首页 , 末页
	private TextBtn shouYe, moYe;
	// 当前界面属于哪种基金
	private String type = "30";
	private int maxPage = 1; // 最大页码
	private int nowpage = 1; // 当前页数
	//
	private JLabel labpage; // 放置当前页数和总页数

	private JTextArea fundRule;
	private String fundRuleText = "基金规则:基金规则说明基金规则说明基金规则说明基金规则说明基金规则说明基金规则说明基金规则说明基金规则说明基金规则说\r\n"
			+ "明基金规则说明基金规则说明基金规则说明";

	private FundBuyGoodsJpanel[] detail = new FundBuyGoodsJpanel[12];

	public FundBuyJpanel() {
		// TODO Auto-generated constructor stub
		this.setPreferredSize(new Dimension(600, 390));
		this.setLayout(null);
		this.setOpaque(false);

		// 放置当前页数和总页数
		labpage = new JLabel(nowpage + "/" + maxPage, SwingConstants.CENTER);
		labpage.setForeground(Color.white);
		labpage.setBounds(335, 378, 58, 17);
		labpage.setFont(UIUtils.TEXT_FONT1);
		this.add(labpage);

		// 30基金
		thridFund = new OptionUncheckBtn("skin/8100226/button/21.png", 1, "￥30 基金", "30基金", this);
		thridFund.setBounds(52, 9, 100, 26);
		// 60基金
		sixthFund = new OptionUncheckBtn("skin/8100226/button/20.png", 1, "￥60 基金", "60基金", this);
		sixthFund.setBounds(152, 9, 100, 26);
		// 90基金
		ninethFund = new OptionUncheckBtn("skin/8100226/button/20.png", 1, "￥90 基金", "90基金", this);
		ninethFund.setBounds(252, 9, 100, 26);

		// 上一页 (caozuo = 4)
		upPage = new CommonBtn("skin/8100226/button/10.png", 1, "", 4);
		upPage.setBounds(315, 379, 18, 18);

		// 下一页 (caozuo = 5)
		downPage = new CommonBtn("skin/8100226/button/9.png", 1, "", 5);
		downPage.setBounds(397, 379, 18, 18);

		// 首页 (caozuo = 1)
		shouYe = new TextBtn("skin/8100226/button/2.png", 1, "首页", 1);
		shouYe.setBounds(280, 379, 34, 17);

		// 末页 (caozuo = 2)
		moYe = new TextBtn("skin/8100226/button/2.png", 1, "末页", 2);
		moYe.setBounds(415, 379, 34, 17);

		fundRule = new JTextArea();
		fundRule.setBounds(70, 40, 550, 76);
		fundRule.setText(fundRuleText);
		fundRule.setOpaque(false);
		fundRule.setFont(UIUtils.TEXT_HY19);

		for (int i = 0; i < detail.length; i++) {
			int row = i % 3;
			int col = i / 3;
			detail[i] = new FundBuyGoodsJpanel();
			detail[i].setBounds(77 + row * 182, 143 + col * 52, 178, 48);
			this.add(detail[i]);
		}

		this.add(fundRule);

		this.add(upPage);
		this.add(downPage);
		this.add(shouYe);
		this.add(moYe);

		this.add(thridFund);
		this.add(sixthFund);
		this.add(ninethFund);
	}

	private ImageIcon iconBack;

	@Override
	protected void paintComponent(Graphics g) {
		// TODO Auto-generated method stub
		super.paintComponent(g);
		if (iconBack == null) {
			iconBack = new ImageIcon("inkImg/old/background/48.png");
		}
		g.drawImage(iconBack.getImage(), 53, 32, 600, 340, this);
	}

	public OptionUncheckBtn getThridFund() {
		return thridFund;
	}

	public void setThridFund(OptionUncheckBtn thridFund) {
		this.thridFund = thridFund;
	}

	public OptionUncheckBtn getSixthFund() {
		return sixthFund;
	}

	public void setSixthFund(OptionUncheckBtn sixthFund) {
		this.sixthFund = sixthFund;
	}

	public OptionUncheckBtn getNinethFund() {
		return ninethFund;
	}

	public void setNinethFund(OptionUncheckBtn ninethFund) {
		this.ninethFund = ninethFund;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

}
